var db = {};
var mysql   = require('mysql');
var pool = mysql.createPool({
  host     : '56f964224a8e6.sh.cdb.myqcloud.com',
  user     : 'cdb_outerroot',
  password : 'cwx!@#123',
  database : 'op',
  port:'6920'
});
 
db.query = function(sql){
	console.log("sql statment",sql)
	return new Promise((resolve,inject)=>{
		if (!sql) {
			inject({errmsg:"sql empty"})
			return
		}
		pool.query(sql, function(err, rows) {
			if (err) {
				inject({errmsg:"sql erro",data:err})
			}else{
				resolve({errmsg:"",data:rows});
			}
		});
	})
	
}
module.exports = db;